
from django_filters.filters import *

from django_filters.rest_framework import FilterSet

from apps.gzde.models import *
from apps.personal_center.models import Address, Order, Order_Evaluate, Construction_Team


class AddressFilter(FilterSet):
    """
    收货地址过滤
    """
    create_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    create_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Address
        fields = ['user','province','city']

class OrdersFilter(FilterSet):
    """
     订单过滤
    """
    create_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    create_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Order
        fields = ['user','order_status','create_time_begin','create_time_end']


class Order_EvaluatesFilter(FilterSet):
    """
     评价过滤
    """
    create_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    create_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Order_Evaluate
        fields = ['evaluate_content','create_time_begin','create_time_end']


class Construction_TeamsFilter(FilterSet):
    """
     施工队伍过滤
    """
    create_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    create_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Construction_Team
        fields = ['construction_team_type','create_time_begin','create_time_end']


class GoodsCategoryFilter(FilterSet):
    """
    商品分类管理过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = GoodsCategory
        fields = ['add_time_begin','add_time_end']


class AttachmentFilter(FilterSet):
    """
    附件管理过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Attachment
        fields = ['name','type','add_time_begin','add_time_end']


class IndexBannerFilter(FilterSet):
    """
    附件管理过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = IndexBanner
        fields = ['name','add_time_begin','add_time_end']